package com.superzqb.asus.superzqbFragment.superzqbJobShop.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.superzqb.asus.superzqb.R;

import java.util.List;
import java.util.Map;


/**
 * Created by asus on 2017/1/21.
 */

public class CampusShopLogisticsAdapter extends BaseAdapter {

    private Context context;
    private List<Map<String, Object>> list;
    private int select =-1;
    public CampusShopLogisticsAdapter(Context context, List<Map<String, Object>>list) {
        this.context = context;
        this.list = list;
    }
    public void setList(List<Map<String, Object>> list) {
        this.list = list;
    }
    @Override
    public int getCount() {
        return list == null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if(convertView==null){
            convertView = LayoutInflater.from(context).inflate(R.layout.campus_logistics_sub_item,parent,false);
            convertView.setTag(new ViewHolder(convertView));
        }
        ViewHolder holder=(ViewHolder) convertView.getTag();
        Map<String,Object> map=list.get(position);
        holder.orderNum.setText("订单编号："+map.get("orderNum"));
        holder.name.setText("收货人："+map.get("name"));
        holder.orderLog.setText("物流："+map.get("orderLog"));
        holder.orderGoods.setText("订单商品："+map.get("orderGoods"));
        holder.orderTime.setText("订单时间："+map.get("orderTime"));
        return convertView;
    }

    public void changeColor(int position) {
        this.select=position;
    }


     class ViewHolder{
        private TextView orderNum,name,orderLog,orderGoods,orderTime;
        public ViewHolder(View view){
            orderNum=(TextView)view.findViewById(R.id.orderNum);
            orderLog=(TextView)view.findViewById(R.id.orderLog);
            name=(TextView)view.findViewById(R.id.name);
            orderGoods=(TextView)view.findViewById(R.id.orderGoods);
            orderTime=(TextView)view.findViewById(R.id.orderTime);
        }

    }
}
